(function(angular) {
	"use strict";
	angular.module("fs.waf").factory("settlementInitFactory", settlementInitFactory);
	settlementInitFactory.$inject = [ "settleInitCustpayService", "settleInitDchargeService", "settleInitLoanService", "settleInitRepayService", "settleInitAmdService", "loggerFactory",
			"settlementInitDefaultService" ];
	function settlementInitFactory(settleInitCustpayService, settleInitDchargeService, settleInitLoanService, settleInitRepayService, settleInitAmdService, loggerFactory, settlementInitDefaultService) {
		var log = loggerFactory.getLogger("settlementInitFactory");
		function getTxnService(settlementInfo) {
			var parentType = settlementInfo.parentType;
			if (parentType == "ISSUE") {
				return settleInitLoanService;
			} else if (parentType == "REPAY") {
				return settleInitRepayService;
			} else if (parentType == "DCHG") {
				return settleInitDchargeService;
			} else if (parentType == "CUSTPAY") {
				return settleInitCustpayService;
			} else if (parentType == "AMD") {
				return settleInitAmdService;
			} else {
				log.debug("not support");
				return null;
			}
		}

		return {
			getTxnService : getTxnService,
			getFunction : getFunction
		};

		function getFunction(settlementInfo, func) {
			var service = getTxnService(settlementInfo);
			if (service) {
				return service[func] ? service[func] : angular.noop;
			} else {
				return settlementInitDefaultService[func] ? settlementInitDefaultService[func] : angular.noop;
			}
		}
	}
})(angular);
